﻿using System;
using System.Collections.Generic;
using System.Text;
using Slaks.Graphs.GraphBuilder;

namespace Slaks.Graphs.Algorithms.DistanceAlgorithm
{
    public class DistMCS4VertexEdgeCount : MCSGraphDistance    
    {
        public DistMCS4VertexEdgeCount () : base ()
        {
			IsVisible = false;
        }

        public DistMCS4VertexEdgeCount(Graph one, Graph two) 
            : base ( one, two )
        {
			IsVisible = false;
        }
		
		public override bool CanOperateOnRepresentation (BuilderType builderType)
		{
			switch(builderType)
			{
	case BuilderType.StandardRepresentationSchenker: 
case BuilderType.ExtractorBuilderNodesOnly:
case BuilderType.StandardRepresentationSlaks:
case BuilderType.SimpleRepresentationSchenker:
case BuilderType.SimpleRepresentationSlaks:
case BuilderType.NDistanceRepresentationSchenker:
case BuilderType.NDistanceRepresentationSlaks:
case BuilderType.NSimpleDistanceRepresentationSchenker:
                        case BuilderType.NSimpleDistanceRepresentationSlaks:
				return true;

			}
			return false;
		}

        /// <summary>
        /// MCS
        /// </summary>
        /// <param name="one"></param>
        /// <param name="two"></param>
        /// <returns></returns>
        public override double GetDistance()
        {
            double maxCommonSubgraphSize = one.GetMCS(two).GetGraphSizeVertexEdgeCount;
            double graphSizeOne = one.GetGraphSizeVertexEdgeCount;
            double graphSizeTwo = two.GetGraphSizeVertexEdgeCount;
            if (maxCommonSubgraphSize == 0.0) return 1;
            return 1 - maxCommonSubgraphSize / Math.Max(graphSizeOne, graphSizeTwo);
        }        
    }
}
